<template>
	<scroll-view :scroll-y="true" class="container999" @touchstart="refreshStart" @touchmove="refreshMove"
		@touchend="refreshEnd">
		<refresh :isTop="isTop" ref="refresh" :needVibrate="true" @isRefresh="isRefresh"></refresh>
		<navTop v-if="client == 'MP-KUAISHOU'" title="我的" :showBack="false" titleColor="black"
			backgroundColor="rgba(0,0,0,0)"></navTop>
		<mineTopTT ref="dYTopBox" v-if="client == 'MP-TOUTIAO'" @updateInfo="updateInfo" @showCz="showCz" :isLogin="isLogin"
			@postLogin="postLogin" :balance="balance" :userInfo="userInfo"></mineTopTT>
		<mineTop ref="kSTopBox" v-if="client == 'MP-KUAISHOU'" @showCz="showCz" :isLogin="isLogin" @postLogin="postLogin" :balance="balance"
			:userInfo="userInfo"></mineTop>
		<view v-if="client == 'MP-KUAISHOU'">
			<view class="alert-box flex justify-between align-center" v-if="!isPhone">
				<view class="flex align-center">
					<!-- <image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/center_icon1.png" class="margin-right-xs img-box1"></image> -->
					为了您的账号安全,请绑定手机号
				</view>
				<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="text-sm">去绑定</button>
				<!-- <text  style="text-decoration: underline;">去绑定</text> -->
			</view>
			<view class="line-box-all">
				<view class="line-set flex justify-between align-center" @tap="handleJump('money')">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/pay_icon2.png"
							class="margin-right-sm img-box2"></image>
						充值记录
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<view class="line-set flex justify-between align-center" @tap="handleJump('history')">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/pay_icon1.png"
							class="margin-right-sm img-box2"></image>
						消费记录
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<view v-if="isViewOrganization" class="line-set flex justify-between align-center" @tap="tapMaster(true)">
					<view class="flex align-center">
						<image  style="width: 52rpx;position: relative;left: -6rpx;" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/appH5/darentg.png" class="margin-right-sm img-box2"></image>
						我要推广
					</view>
					<view>
						<image class="text-sm text-gray image-right" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/appH5/daren_new.png"></image>
					<text class="lg text-gray cuIcon-right"></text>
					</view>
				</view>
				<button 
					class="line-set flex justify-between align-center" 
					hover-class="none"
					:style="{
						backgroundColor: '#ffffff',
						boxShadow: 'none'
					}" 
					open-type="openProfile"  
					:user="`${concatId}`"
				>
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/center_icon2.png"
							class="margin-right-sm img-box2"></image>
						客服咨询
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</button>
				<view class="line-set flex justify-between align-center" @tap="toLovePage">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/center_icon4.png"
							class="margin-right-sm img-box2"></image>
						我的喜欢
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<view class="line-set flex justify-between align-center" @tap="toSetPage">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/center_icon3.png"
							class="margin-right-sm img-box2"></image>
						系统设置
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
			</view>
		</view>

		<!-- 头条设置 -->
		<view v-if="client == 'MP-TOUTIAO'">
			<view class="alert-box flex justify-between align-center" v-if="!isPhone">
				<view class="flex align-center">
					<!-- <image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/center_icon1.png" class="margin-right-xs img-box1"></image> -->
					为了您的账号安全,请绑定手机号
				</view>
				<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumberDouYin" class="text-sm">去绑定</button>
				<!-- <text  style="text-decoration: underline;">去绑定</text> -->
			</view>
			<view class="line-box-all">
				<view class="line-set flex justify-between align-center" @tap="handleJump('money')">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/toutiao/pay_icon1.png"
							class="margin-right-sm img-box2"></image>
						充值记录
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<view class="line-set flex justify-between align-center" @tap="handleJump('history')">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/toutiao/pay_icon2.png"
							class="margin-right-sm img-box2"></image>
						消费记录
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<!-- <view v-if="isViewOrganization" class="line-set flex justify-between align-center" @tap="tapMaster(true)">
					<view class="flex align-center">
						<image style="width: 52rpx;" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/appH5/daren_ks.png" class="margin-right-sm img-box2"></image>
						我要推广
					</view>
					<view>
						<image class="text-sm text-gray image-right" src="https://res.qiguoread.com/staticResources/fellow_townsman/image/appH5/daren_new.png"></image>
					<text class="lg text-gray cuIcon-right"></text>
					</view>
				</view> -->
				<button 
					class="line-set flex justify-between align-center" 
					hover-class="none"
					:style="{
						backgroundColor: '#ffffff',
						boxShadow: 'none'
					}" 
					open-type="contact"
				>
					<view 
						class="flex align-center" 
						:style="{
							marginRight: '180rpx'
						}"
					>
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/toutiao/center_icon1.png" class="margin-right-sm img-box2"></image>
						客服咨询
					</view>
					<text class="text-sm text-gray">周一至周五9：30-18：30</text>
					<text class="lg text-gray cuIcon-right"></text>
				</button>
				<view class="line-set flex justify-between align-center" @tap="toLovePage">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/toutiao/center_icon2.png"
							class="margin-right-sm img-box2"></image>
						我的喜欢
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<view class="line-set flex justify-between align-center" @tap="toSetPage">
					<view class="flex align-center">
						<image src="https://res.qiguoread.com/staticResources/fellow_townsman/image/uni/toutiao/center_icon3.png"
							class="margin-right-sm img-box2"></image>
						系统设置
					</view>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
				<!-- <button open-type="im" data-order-id="38285559" data-i-type="2"  :data-im-id="imId" @im="imCallback" @error="onImError">IM客服</button> -->
			</view>
		</view>
		<!-- <view v-if="client == 'MP-KUAISHOU'" style="width: 100vw;background-color: #F5F5F5;height: 20rpx;"></view> -->

		<!-- <navTab
			v-if="client == 'MP-TOUTIAO'"
			:navType="5"
			ref="navTab"
			style="margin-top: 20rpx;margin-bottom: 20rpx;"
			@toTop="toTop"
			:tabTitle="tabTitle"
			@changeTab="changeTab"
		></navTab>
		<swiper :style="{ height: screenHeightShow }" :current="currentTab" @change="swiperTab"  v-if="client == 'MP-TOUTIAO'" >
			<swiper-item v-for="(listItem, listIndex) in list" :key="listIndex">
				<scroll-view @scroll="isScroll" style="height: 100%;" scroll-y="true" @scrolltolower="lower1">
					<view class="content">
						<view class="imgItem" v-for="(cardItem, cardIndex) in listItem" @longpress="cancleZj(cardItem.id)" :key="cardItem.id" @click="toDetail(cardItem)">
							<view class="imgBox">
								<view v-if="client == 'MP-KUAISHOU'" class="sequence">{{ cardItem.compilationsName || cardItem.title }}</view>
								<image class="imgBox" lazy-load :src="cardItem.coverImgUrl || cardItem.coverImageUrl"></image>
							</view>
							<view v-if="listIndex != 2 && client == 'MP-KUAISHOU'" class="seq">
								{{ cardItem.alreadyWatchSequence && cardItem.alreadyWatchSequence != -1 ? cardItem.alreadyWatchSequence + 1 : 1 }}集/{{
									cardItem.uploadOfEpisodes
								}}集
							</view>
							<view v-if="listIndex == 2 && client == 'MP-KUAISHOU'" class="seq">第{{ cardItem.sequence + 1 }}集</view>
							
							
							<view v-if="listIndex == 2 && client == 'MP-TOUTIAO'" class="nameBox">
									<view style="width: 230rpx;color: #333333;font-size: 28rpx;margin-top: 13rpx;" class="clamp">
										{{ cardItem.compilationsName || cardItem.title }}
									</view>
									<view style="color: #999999;font-size: 24rpx;margin-top: 3rpx;margin-bottom: 20rpx;font-size: 24rpx;">
										第{{ cardItem.sequence + 1 }}集
									</view>
							</view>
							
							<view v-if="client == 'MP-TOUTIAO' && listIndex != 2" class="nameBox">
								<view style="width: 230rpx;color: #333333;font-size: 28rpx;margin-top: 13rpx;" class="clamp">
									{{ cardItem.compilationsName || cardItem.title }}
								</view>
								<view style="color: #999999;font-size: 24rpx;margin-top: 3rpx;margin-bottom: 20rpx;font-size: 24rpx;">
									{{ cardItem.alreadyWatchSequence && cardItem.alreadyWatchSequence != -1 ? cardItem.alreadyWatchSequence + 1 : 1 }}集/{{
										cardItem.uploadOfEpisodes
									}}集
								</view>
							</view>
						</view>
						<view class="imgItem" v-if="listItem.length % 3 == 2"><view class="imgBox"></view></view>
					</view>
					<view @click.stop="lower1" class="loadMoreBox" v-if="list[listIndex].length > 3">
						<loadMore @loadMore="lower1">
							<view class="loadMore">{{ noMore[listIndex] == 1 ? '到底啦，别再拉了～' : noMore[listIndex] == 0 ? '加载更多' : '加载中' }}</view>
						</loadMore>
					</view>
					<view class="noCard" v-if="listItem.length === 0 && !hasLoad[listIndex]">加载中</view>
					<noData v-if="listItem.length === 0 && hasLoad[listIndex]"></noData>
					<view class="statu-space" :style="{ height: statusBarHeight + 'px' }"></view>
				</scroll-view>
			</swiper-item>
		</swiper> -->
		<!-- #ifdef MP-TOUTIAO -->
		<moneyPopupTT @czSuccess="czSuccess" @getListSuccess="getListSuccess" v-if="showMoney" @isClose="moneyClose"
			:balance="balance" fromPage="mine"></moneyPopupTT>
		<!-- #endif -->
		<!-- #ifdef MP-KUAISHOU -->
		<moneyPopup @czSuccess="czSuccess" @getListSuccess="getListSuccess" v-if="showMoney" @isClose="moneyClose"
			:balance="balance" fromPage="mine"></moneyPopup>
		<!-- #endif -->
		<!-- #ifdef MP-TOUTIAO -->
		<insertAdTt ref="insertAdTt" />
		<!-- #endif -->
		<!-- 推广弹窗 -->
		<mountPopup :viewShow="masterShow" @isClose="tapMaster"></mountPopup>
	</scroll-view>
</template>

<script>
import refresh from '../../components/refresh.vue';
import navTab from '../../components/navTab.vue';
const util = require('../../util/util.js');
import moneyPopup from '../../components/moneyPopup.vue';
import moneyPopupTT from '../../components/moneyPopupTT.vue';
import mineTop from './components/mineTop.vue';
import mineTopTT from './components/mineTopTT.vue';
import mountPopup from '../video/components/mountPopup.vue'
import insertAdTt from '../video/components/insertAdTt.vue';
export default {
	components: { refresh, moneyPopup, navTab, mineTop, mineTopTT, moneyPopupTT, mountPopup, 
		insertAdTt 
	},
	data() {
		return {
			imId: '22329354662',
			clientName: this.clientName,
			screenHeightShow: 667,
			statusBarHeight: uni.getSystemInfoSync()['statusBarHeight'] || 20,
			list: [[], [], []],
			hasLoad: [false, false, false],
			noMore: [0, 0, 0],
			pages: [1, 1, 1],
			currentTab: 0,
			tabTitle: ['我的追剧', '观看历史', '点赞记录'],
			showMoney: false,
			isLogin: uni.getStorageSync('alreadyAuthLogin') ? true : false,
			userInfo: uni.getStorageSync('userInfo') || {},
			balance: 0,
			isTop: true,
			client: '',
			concatId: '',
			isPhone: true,
			loginJsCode: '', // 抖音登录JsCode
			masterShow:false,
			isViewOrganization: false
		};
	},
	computed: {},
	async onShow() {
		this.isLogin = uni.getStorageSync('alreadyAuthLogin') ? true : false;
		this.userInfo = uni.getStorageSync('userInfo') || {};
		this.getBalance();
		this.getList('refresh');
		//#ifdef MP-KUAISHOU
		this.toConcatPage()
		this.getUserInfoMess()


		//#endif
		this.isIos = getApp().globalData.isIos;
		//#ifdef MP-TOUTIAO
		this.getLoginMess()
		this.getUserInfoMess()

		// 从IM返回
		let imJump = uni.getStorageSync('imJump')
		let imJumpNewObj = uni.getStorageSync('imJumpNewObj')
		if(imJumpNewObj) { // 通用支付IOS同步订单
			let { orderId } = imJumpNewObj
			console.log('触发订单同步-----', orderId)
			await getApp().czSucc(this, orderId)
			uni.removeStorageSync('imJumpNewObj')
		}
		if (imJump) {
			this.czSuccess({
				type: 'ssVipSuccess'
			})
			uni.removeStorageSync('imJump')
		}
		const currentTimestamp = Math.floor(Date.now() / 1000);
		if (currentTimestamp - getApp().globalData.lastAdTimestamp > 180 && !getApp().globalData.isAdComeCheck) {
			// 曝光插屏广告
			// let _this = this
			console.log('Show interstitial ad');
			setTimeout(() => {
                this.$refs.insertAdTt && this.$refs.insertAdTt.isShowAd()
            }, 200)
			console.log(this.$refs.insertAdTt,'this.$refs.insertAdTt-------');
			// getApp().globalData.lastAdTimestamp = currentTimestamp;
		} else {
			console.log('Skip interstitial ad');
		}
		//#endif
		//曝光推广按钮
		this.$statis({
			action:'EXPOSURE',
			position:'pages/index_top_3'
		})
	},
	onLoad(e) {
		this.isViewOrganization = getApp().globalData.isViewOrganization
		//#ifdef MP-KUAISHOU
		this.client = 'MP-KUAISHOU';
		//#endif
		//#ifdef MP-TOUTIAO
		this.client = 'MP-TOUTIAO';
		tt.showFavoriteGuide({
			type: "bar",
			content: "一键添加到「我的小程序」",
			position: "bottom",
			success(res) {
				console.log("引导组件展示成功", res);
			},
			fail(err) {
				console.log("引导组件展示失败", err);
			},
		});
		//#endif
		
	},
	onReady() {
		this.screenHeightShow = `calc(${uni.getSystemInfoSync()['screenHeight'] || 667}px - 320rpx - 90rpx - 94rpx - 20rpx - 100rpx - ${this.statusBarHeight
			}px - env(safe-area-inset-bottom))`;
	},
	onShareAppMessage: function () {
		var shareJson = {
			path: '/pages/fx_xjc/fx_xjc',
			data: {
				page: 'mine',
				sharePosition: '/pages/fx_xjc/fx_xjc',
				from: '/position/share/share',
				sharePage: '/pages/fx_xjc/fx_xjc'
			}
		};
		// 达人分享批次
		console.log(getApp().globalData.shareBatchId)
		if (getApp().globalData.shareBatchId) {
			shareJson.channel = 'video'
			shareJson.extra = {
				hashtag_list: ['精彩短剧热播中👈']
			}
		}
		shareJson.title = '精彩短剧热播中👈';
		return this.formatShare(shareJson);
	},
	onHide() { },
	methods: {
		tapMaster(e) {
			this.masterShow = e
		},
		imCallback(e) {
			console.log('客服回调信息', e)
		},
		onImError(e) {
			console.log('客服错误', e)
		},
		handleJump(type) {
			uni.navigateTo({
				url: `../pay_history/pay_history?type=${type}`
			})
		},
		getLoginMess() {
			let _this = this
			uni.login({
				success(res) {
					_this.loginJsCode = res.code
				},
				fail(error) {
					console.log(error)
				}
			})
		},
		async getUserInfoMess() {
			try {
				let res = await this.zwyRequest({
					url: `/user/login_user/info`,
					method: 'GET',
					params: {
						isUser: true
					}
				})

				if (res && res.mobile) {
					this.isPhone = true
				} else {
					this.isPhone = false
				}
			} catch (error) {
				console.log(error)
			}
		},
		async getPhoneNumber(e) {
			try {
				if (!e.detail.iv) {
					uni.showToast({
						title: '授权失败！',
						icon: 'none'
					});
					return;
				}
				let that = this
				uni.login({
					success: async (res) => {
						let data = await this.zwyRequest({
							url: '/user/mobile_login/binding_kuai_shou_mobile',
							method: 'PUT',
							data: {
								jsCode: res.code,
								data: e.detail.encryptedData,
								iv: e.detail.iv
							}
						})

						console.log('data====', data)
						if (data) {
							uni.showToast({
								title: `绑定成功`,
								icon: 'none'
							})

							setTimeout(() => {
								that.getUserInfoMess()
							}, 300)
						}

					}
				})
			} catch (error) {
				console.log(error)
			}
		},

		async getPhoneNumberDouYin(e) {
			try {
				if (!e.detail.iv) {
					uni.showToast({
						title: '授权失败！',
						icon: 'none'
					});
					return;
				}

				let that = this
				let data = await this.zwyRequest({
					url: '/user/mobile_login/binding_dou_yin_mobile',
					method: 'PUT',
					data: {
						jsCode: this.loginJsCode,
						data: e.detail.encryptedData,
						iv: e.detail.iv
					}
				})

				console.log('data====', data)
				if (data) {
					uni.showToast({
						title: `绑定成功`,
						icon: 'none'
					})

					setTimeout(() => {
						that.getUserInfoMess()
					}, 300)
				}

				// uni.login({
				// 	success: async (res) => {


				// 	}
				// })
			} catch (error) {
				console.log(error)
			}
		},
		// 添加订阅提醒
		async handleAddMess() {
			try {
				if (this.$store.state.subscribeMess) {
					uni.showToast({
						title: '订阅消息已设置',
						icon: 'none'
					})
					return
				}
				uni.requestSubscribeMessage({
					tmplIds: ['EO_kGKFovH9paq6XZ3gS9'],
					success: (res) => {
						this.$store.state.subscribeMess = true
						if (res.EO_kGKFovH9paq6XZ3gS9 === 'ACCEPT') {
							uni.showToast({
								title: '订阅消息已开启',
								icon: 'none'
							})
						} else if (res.EO_kGKFovH9paq6XZ3gS9 === 'REFUSE') {
							uni.showToast({
								title: '请在程序设置中开启接收订阅',
								icon: 'none'
							})
						}
					},
					fail: (error) => {
						console.log('error', error)
					},
					complete: (end) => {
						console.log('end', end)
					}
				})
			} catch (error) {
				console.log(error)
			}
		},
		toLovePage() {
			uni.navigateTo({
				url: '../love_video/love_video'
			})
		},
		// 获取服务号ID
		async toConcatPage(e) {
			try {
				let res = await this.getConfig()
				console.log('config====', res)
				this.concatId = res.concatId
			} catch (error) {
				console.log(error)
			}
		},
		toSetPage() {
			uni.navigateTo({
				url: '../setPage/setPage'
			})
		},
		cancleZj(id) {
			if (this.currentTab == 0) {
				console.log('取消追剧', id);

				this.zwyRequest({
					url: '/cdp/compilations/unsubscribe',
					data: {
						"_method": "DELETE",
						id: id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
					},
					method: 'post'
				}).then(res => {
					uni.showToast({
						title: '取消追剧成功',
						icon: 'none'
					})
					this.isRefresh();
				});
			}
		},
		isScroll(e) {
			if (e.detail.scrollTop <= 40) this.isTop = true;
			else this.isTop = false;
		},
		// 刷新touch监听
		refreshStart(e) {
			this.$refs.refresh.refreshStart(e);
		},
		refreshMove(e) {
			this.$refs.refresh.refreshMove(e);
		},
		refreshEnd(e) {
			this.$refs.refresh.refreshEnd(e);
		},
		isRefresh() {
			this.getList('refresh');
		},
		toDetail(item) {
			console.log('item', item);
			let tempUrl = `../video/video?fakeId=${item.fakeId || item.compilationsFakeId}&compilationId=${item.compilationId || item.compilationsId}`;
			if (item.sequence) tempUrl += `&enterSequence=${item.sequence}`;
			this.zwyRouter(tempUrl);
		},
		lower1: util.throttle(function (e) {
			this.getList('loadMore');
		}, 360),
		swiperTab: async function (e) {
			var index = e.detail.current; //获取索引
			await this.$nextTick()
			this.$refs.navTab && this.$refs.navTab.longClick(index);
			this.currentTab = index;
			if (this.list[index].length === 0) this.getList();
		},
		getList(type = 'refresh') {
			let tempIndex = this.currentTab;
			let tempPageNum = this.pages[tempIndex];
			if (type == 'refresh') {
				tempPageNum = 1;
				this.hasLoad[tempIndex] = false;
				this.noMore[tempIndex] = 0;
			}
			if (this.noMore[tempIndex] != 0) {
				return;
			}
			this.noMore[tempIndex] = 2;
			this.noMore = JSON.parse(JSON.stringify(this.noMore));
			let postData = {};
			let tempUrl = '';
			if (tempIndex == 0) {
				postData['pageNum'] = tempPageNum;
				tempUrl = '/cdp/user_subscribe/compilations';
			} else if (tempIndex == 1) {
				tempUrl = `/cdp/user_history/compilations?pageNum=${tempPageNum}&pageSize=10`;
			} else if (tempIndex == 2) {
				tempUrl = `/cdp/user_favorite/list?pageNum=${tempPageNum}`;
			}

			this.zwyRequest({
				url: tempUrl,
				data: postData
			}).then(res => {
				console.log('getList', res);
				let check = Array.isArray(res);
				if (!check) {
					this.noMore[tempIndex] = 0;
					this.pages[tempIndex]--;
					return;
				}
				if (tempIndex == 2) {
					res = res.map(item => {
						return { ...item, ...item['episodicDrama'] };
					});
				}
				let tempList = this.list;

				if (type == 'refresh') {
					tempList[tempIndex] = res;
					tempPageNum = 2;
				} else {
					tempList[tempIndex] = tempList[tempIndex].concat(res);
					tempPageNum++;
				}
				console.log('tempList', tempList);
				this.noMore[tempIndex] = res.length === 0 ? 1 : 0;
				this.pages[tempIndex] = tempPageNum;
				this.hasLoad[tempIndex] = true;
				this.hasLoad = JSON.parse(JSON.stringify(this.hasLoad));
				this.list = JSON.parse(JSON.stringify(tempList));
				this.noMore = JSON.parse(JSON.stringify(this.noMore));
				if (this.$refs.refresh) this.$refs.refresh.endAfter(); //刷新结束调用
				this.$forceUpdate();
			});
		},
		changeTab(index) {
			this.currentTab = index;
			console.log('index', index);
		},
		toTest() {
			console.log('toTest');
			uni.navigateTo({
				url: '../toTest/toTest'
			});
		},
		showCz() {
			console.log(121212)
			this.showMoney = true;
		},
		getListSuccess() {
			uni.hideTabBar();
		},
		moneyClose() {
			uni.showTabBar();
			this.showMoney = false;
		},
		async czSuccess(val) {
			uni.showTabBar();
			this.showMoney = false;
			if(val && val.type === 'ssVipSuccess') {
				// 更新会员状态
				//#ifdef MP-KUAISHOU
				this.$refs.kSTopBox.memberStatusUpdate()
				//#endif
				//#ifdef MP-TOUTIAO
				this.$refs.dYTopBox.memberStatusUpdate()
				//#endif
			}
			this.getBalance()
		},
		
		getBalance() {
			this.zwyRequest({
				header: {
					'content-type': 'application/json;charset=UTF-8'
				},
				url: '/wealth/api/balance/user_balance'
			}).then(res => {
				console.log('getBalance', res);
				if (res) this.balance = res;
			});
		},
		postLogin: util.throttle(async function () {
			if (this.isLogin) return;

			//#ifdef MP-KUAISHOU
			uni.getUserInfo({
				success: res => {
					console.log('postLogin', res);
					this.updateInfo(res.userInfo.nickName, res.userInfo.avatarUrl);
				}
			});
			//#endif
		}, 2000),
		updateInfo(nickName, avatarUrl) {
			uni.showLoading({
				title: '登录中',
				mask: true
			});
			let postUrl = '/user/login_user/update_kuaishou_user_info';

			//#ifdef MP-TOUTIAO
			postUrl = '/user/login_user/update_douyin_user_info'
			//#endif

			// this.userInfo = res.userInfo;
			this.zwyRequest({
				url: postUrl,
				method: 'POST',
				data: {
					nickName: nickName,
					iconUrl: avatarUrl
				}
			}).then(resUpdate => {
				console.log('postLogin', resUpdate);
				this.zwyLogin().then(resLogin => {
					console.log('zwyLogin', resLogin);
					setTimeout(() => {
						uni.hideLoading();
						this.userInfo = uni.getStorageSync('userInfo') || {};
						this.isLogin = true;
						uni.setStorageSync('alreadyAuthLogin', true);
						this.getBalance();
						this.$forceUpdate();
					}, 500);
				});
			});
		},
		loginout() {
			console.log('loginout');
			this.isLogin = false;
			uni.setStorageSync('alreadyAuthLogin', false);
			this.userInfo = {};
		},
		isCopy() {
			uni.setClipboardData({
				data: 'aiyufeimmmm',
				success: function () { }
			});
		}
	}
};
</script>

<style lang="scss">
.sequence {
	text-align: center;
	line-height: 59rpx;
	display: -webkit-box;
	word-break: break-all;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	position: absolute;
	bottom: 0;
	width: 92%;
	padding: 0 4%;
	margin: auto;
	left: 0;
	right: 0;
	height: 59rpx;
	z-index: 88;
	background: rgba(0, 0, 0, 0.5);
	color: white;
	font-size: 28rpx;
}

.imgItem {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
}

.seq {
	text-align: center;
	line-height: 52rpx;
	width: 174rpx;
	height: 52rpx;
	color: #fd6f9f;
	font-size: 26rpx;
	border-radius: 26rpx;
	margin-bottom: 30rpx;
	margin-top: 16rpx;
	border: 1rpx solid #e1e1e1;
}

.noCard {
	width: 90vw;
	height: 200rpx;
	margin: auto;
	background-color: white;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #999999;
}

.content {
	display: flex;
	flex-wrap: wrap;
	width: 100vw;
	padding: 0 2%;
	box-sizing: border-box;
	justify-content: space-between;
}

.loadMore {
	background-color: #ffffff;
	padding: 0 23rpx;
	position: relative;
	z-index: 11;
}

.loadMoreBox::before {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	width: 90vw;
	height: 2rpx;
	background-color: #d9d9d9;
	margin: auto;
}

.loadMoreBox {
	position: relative;
	height: 60rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100vw;
	font-size: 22rpx;
	color: #c3c3c3;
}

//#ifdef MP-TOUTIAO
.imgBox {
	overflow: hidden;
	position: relative;
	width: 230rpx;
	border-radius: 13rpx;
	height: 315rpx;
}

//#endif

//#ifdef MP-KUAISHOU
.imgBox {
	overflow: hidden;
	position: relative;
	width: 230rpx;
	border-radius: 13rpx;
	// height: 342rpx;
	height: 315rpx;
}

//#endif
.wealthBox {
	.czBtn {
		font-size: 28rpx;
		width: 209rpx;
		height: 67rpx;
		background: linear-gradient(339deg, #f36d86 0%, #ff70a2 100%);
		border-radius: 34rpx;
		line-height: 67rpx;
		color: white;
		text-align: center;
	}

	width: 90vw;
	display: flex;
	align-items: center;
	justify-content: space-between;

	.wealthItem {
		.wealthItemBottom {
			color: #333333;
			font-size: 28rpx;
		}

		.wealthItemTop {
			font-size: 28rpx;
			color: #999999;
		}

		justify-content: center;
		display: flex;
		align-items: center;
		flex-direction: column;
	}
}

.version {
	width: 100vw;
	height: 80rpx;
	line-height: 80rpx;
	text-align: center;
	color: #ccc;
	font-weight: bold;
	position: absolute;
	left: 0;
	bottom: 30rpx;
}

.userBoxLeft {
	display: flex;
	align-items: center;
	justify-content: flex-start;
}

.navTop {
	position: fixed;
	top: 0;
	left: 0;
}

.lineLeft {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-left: 50rpx;
}

.line {
	border-bottom: 1rpx solid rgba(221, 221, 221, 1);
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 80rpx;
	line-height: 80rpx;
}

.container {
	flex-direction: column;
	height: 100%;
}

.btn-cz {
	width: 180rpx;
	height: 68rpx;
	line-height: 68rpx;
	text-align: center;
	padding: 0 30rpx;
	background: linear-gradient(to right, #ffff82, #ffa631);
	border-radius: 36rpx;
	font-size: 28rpx;
	color: #6e4c20;
}

.userBox {
	width: 90%;
	display: flex;
	align-items: center;
	justify-content: space-between;

	.moneyText {
		padding-left: 10rpx;
		margin-top: 12rpx;
		font-size: 30rpx;
		color: #333333;
	}

	.loginBtn {
		flex-direction: column;
		justify-content: center;
		align-items: flex-start;

		.loginText {
			font-weight: bold;
			font-size: 36rpx;
			color: black;
		}
	}

	.userImg {
		margin-right: 22rpx;
		width: 122rpx;
		height: 122rpx;
		border-radius: 50%;
	}
}

.container999 {
	width: 100vw;
	min-height: 100vh;
	overflow: hidden;
	background: #ffffff;
}

.topBox {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-around;
	width: 100%;
	height: 320rpx;
	background-size: 100% 120%;
}

.alert-box {
	font-size: 30rpx;
	color: #636A83;
	width: 750rpx;
	height: 74rpx;
	background: linear-gradient(90deg, #E8EDF8 0%, #F6EFF8 100%);
	padding: 0 53rpx 0 33rpx;

	.img-box1 {
		width: 34rpx;
		height: 30rpx;
	}

	.text-sm {
		width: 96rpx;
		height: 52rpx;
		line-height: 52rpx;
		border: none;
		box-shadow: none;
		background: none;
		color: rgb(255, 111, 162);
		text-decoration: underline;
		font-size: 28rpx;
		margin: 0;
		padding: 0;

		&::after {
			border: 0;
		}
	}
	
}
.image-right{
	width: 72rpx;
	height: 33rpx;
	position: relative;
	top: 2rpx;
}
.line-box-all {
	padding-left: 24rpx;
	margin-bottom: 88rpx;
}

.line-set {
	height: 120rpx;
	width: 100%;
	font-size: 32rpx;
	color: #333333;
	border-bottom: 1rpx solid #eeeeee;
	padding: 0 32rpx;

	.img-box2 {
		width: 40rpx;
		height: 39rpx;
	}

	&::after {
		border: none !important;
	}
}</style>
